import request from '@/utils/request'
// import axios from 'axios'
import { apiVersion } from '@/config'
// import { getDeviceId } from '@/utils/tool'


// 用户信息
export function usersInfo(data) {
    return request({
        url: `/user/${apiVersion}/user/info`,
        method: 'get',
        data
    })
}

// 二次登陆（切换用的）
export function changeOrgAuthToken(data) {
    let params = ''
    for (let i in data) {
        params += `${i}=${data[i]}&`
    }
    return request({
        url: `/serv-auth/oauth/token?${params}`,
        method: 'post',
        data
    })
}
// 验证码
export function verificationCode(data) {
    return request({
        url: `/api/${apiVersion}/auth/code`,
        method: 'get',
        data
    })
}
// 登录
export function login(data) {
    let params = ''
    for (let i in data) {
        params += `${i}=${data[i]}&`
    }
    return request({
        url: `/api/${apiVersion}/auth/login?${params}`,
        method: 'post',
        data
    })
}
// 用户列表
export function userLis(data) {
    return request({
        url: `/user/${apiVersion}/user`,
        method: 'get',
        data
    })
}
// 获取所有用户
export function userAll(data) {
    return request({
        url: `/user/${apiVersion}/user/all`,
        method: 'get',
        data
    })
}
// 添加用户
export function addUser(data) {
   
    return request({
        url: `/user/${apiVersion}/user/createByAdmin`,
        method: 'post',
        data
    })
}
// 修改用户
export function putUser(data) {
    return request({
        url: `/user/${apiVersion}/user`,
        method: 'put',
        data
    })
}
// 删除用户
export function delUser(data) {
    return request({
        url: `/user/${apiVersion}/user/${data.id}`,
        method: 'delete',
        data
    })
}
// 获取用户详情
export function getUserDetail(data) {
    return request({
        url: `/user/${apiVersion}/user/${data.id}`,
        method: 'get',
        data
    })
}
// 重置密码
export function initPassword(data) {
    return request({
        url: `/user/${apiVersion}/user/${data.id}/resetPassword`,
        method: 'post',
        data
    })
}
